Skip to content

Conversation

@brfrn169
Copy link
Collaborator

@brfrn169 brfrn169 commented Nov 20, 2025

Description

This PR introduces a new method isConsistentReadGuaranteed() method to the StorageInfo interface to indicate whether a storage backend guarantees consistent reads within its atomicity unit. It also renames MutationAtomicityUnit to the more general AtomicityUnit to better reflect that atomicity applies to all operations, not just mutations.

Implementation:

  • Cassandra: Returns true (guarantees consistent reads within partitions)
  • Cosmos DB: Returns true (guarantees consistent reads within partitions)
  • DynamoDB: Returns false (currently does not guarantee consistent reads as Scan and Query support READ_COMMITTED isolation level)
  • JDBC: Dynamically determines based on the database's transaction isolation level:
    • MySQL/MariaDB: true if isolation level is REPEATABLE READ or SERIALIZABLE
    • PostgreSQL/YugabyteDB: true if isolation level is REPEATABLE READ or SERIALIZABLE
    • Oracle: true if isolation level is SERIALIZABLE
    • SQL Server: true if isolation level is REPEATABLE READ or SERIALIZABLE
    • SQLite: true if isolation level is SERIALIZABLE
    • DB2: true if isolation level is REPEATABLE READ or SERIALIZABLE

Related issues and/or PRs

N/A

Changes made

  • Added StorageInfo#isConsistentReadGuaranteed() method to indicate whether a storage backend guarantees consistent reads within its atomicity unit
  • Renamed StorageInfo.MutationAtomicityUnit enum to StorageInfo.AtomicityUnit to reflect that atomicity applies to both reads and mutations
  • Renamed getMutationAtomicityUnit() to getAtomicityUnit() in the StorageInfo interface
  • Added warning to DistributedStorageAdmin#getStorageInfo() that this feature is primarily for internal use and subject to breaking changes

Checklist

The following is a best-effort checklist. If any items in this checklist are not applicable to this PR or are dependent on other, unmerged PRs, please still mark the checkboxes after you have read and understood each item.

  • I have commented my code, particularly in hard-to-understand areas.
  • I have updated the documentation to reflect the changes.
  • I have considered whether similar issues could occur in other products, components, or modules if this PR is for bug fixes.
  • Any remaining open issues linked to this PR are documented and up-to-date (Jira, GitHub, etc.).
  • Tests (unit, integration, etc.) have been added for the changes.
  • My changes generate no new warnings.
  • Any dependent changes in other PRs have been merged and published.

Additional notes (optional)

N/A

Release notes

Added isConsistentReadGuaranteed() method to the StorageInfo interface to indicate whether a storage backend guarantees consistent reads within its atomicity unit. Also renamed MutationAtomicityUnit to AtomicityUnit to better reflect that atomicity applies to all operations, not just mutations.

@brfrn169 brfrn169 self-assigned this Nov 20, 2025
Copilot AI review requested due to automatic review settings November 20, 2025 13:54
@brfrn169 brfrn169 added the enhancement New feature or request label Nov 20, 2025
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @brfrn169, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the StorageInfo interface by introducing a mechanism to explicitly state whether a storage backend guarantees consistent reads within its atomicity unit. It also refactors the MutationAtomicityUnit enum to a more broadly applicable AtomicityUnit, clarifying that atomicity concepts extend beyond just data modification. These changes provide a more precise way to communicate storage capabilities, particularly for read consistency, and ensure that various storage implementations correctly report their properties.

Highlights

  • New isConsistentReadGuaranteed() Method: A new method isConsistentReadGuaranteed() has been added to the StorageInfo interface, allowing storage backends to indicate whether they guarantee consistent reads within their atomicity unit.
  • Renaming of MutationAtomicityUnit to AtomicityUnit: The MutationAtomicityUnit enum has been renamed to AtomicityUnit to better reflect that atomicity applies to all operations (reads and mutations), not just mutations. Corresponding method getMutationAtomicityUnit() was also renamed to getAtomicityUnit().
  • Dynamic Consistent Read Guarantee for JDBC: The JDBC storage implementation now dynamically determines its isConsistentReadGuaranteed() status based on the current transaction isolation level and the minimum isolation level required for consistent reads by the specific RDB engine.
  • Updated StorageInfoImpl Constructor: The StorageInfoImpl constructor has been updated to include the new consistentReadGuaranteed boolean field, and all existing storage implementations (Cassandra, Cosmos, Dynamo, Object Storage) have been updated to provide this information.
  • Javadoc Warning for getStorageInfo(): A warning has been added to the Javadoc of DistributedStorageAdmin#getStorageInfo(), indicating that this feature is primarily for internal use and subject to breaking changes.
  • RDB Engine Strategy Enhancements: Each RDB engine strategy (e.g., MySQL, PostgreSQL, Oracle) now implements a getMinimumIsolationLevelForConsistencyRead() method, which is used by the JDBC admin to determine read consistency guarantees.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new isConsistentReadGuaranteed() method to the StorageInfo interface and renames MutationAtomicityUnit to the more general AtomicityUnit. The changes are well-implemented and consistently applied across the codebase. The dynamic determination of consistency guarantees for JDBC based on transaction isolation levels is a particularly nice improvement. I have a couple of minor suggestions for consistency and clarity.

Copilot finished reviewing on behalf of brfrn169 November 20, 2025 13:58
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces a new method isConsistentReadGuaranteed() to the StorageInfo interface to indicate whether a storage backend guarantees consistent reads within its atomicity unit. It also refactors the naming from MutationAtomicityUnit to AtomicityUnit to reflect that atomicity applies to all operations, not just mutations.

Key changes:

  • Added isConsistentReadGuaranteed() method to indicate read consistency guarantees
  • Renamed MutationAtomicityUnit enum to AtomicityUnit and updated all references
  • Implemented JDBC-specific logic to dynamically determine consistent read guarantees based on database isolation levels

Reviewed Changes

Copilot reviewed 38 out of 38 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
StorageInfo.java Added isConsistentReadGuaranteed() method and renamed enum from MutationAtomicityUnit to AtomicityUnit
StorageInfoImpl.java Added consistentReadGuaranteed field and updated constructor, equals, hashCode, and toString methods
DistributedStorageAdmin.java Added warning about internal use of getStorageInfo() method
DistributedStorage.java Updated Javadoc references from MutationAtomicityUnit to AtomicityUnit
Various storage admin implementations Updated to pass consistentReadGuaranteed parameter (Cassandra, Cosmos, Dynamo, ObjectStorage)
RdbEngineStrategy.java Added getMinimumIsolationLevelForConsistencyRead() method interface
Various RDB engine implementations Implemented getMinimumIsolationLevelForConsistencyRead() for each database engine
JdbcAdmin.java Dynamically determines consistentReadGuaranteed based on connection isolation level
Test files Updated test method names and enum references from MutationAtomicityUnit to AtomicityUnit

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@brfrn169 brfrn169 force-pushed the add-isConsistentReadGuaranteed-to-StorageInfo branch from 69c0c67 to 4e9a18e Compare November 20, 2025 14:44
@feeblefakie
Copy link
Contributor

feeblefakie commented Nov 21, 2025

@brfrn169 I'm confused about the definition of isConsistentReadGuaranteed.
Is it a property of a transaction whether we get consistent results from multiple read operations in a transaction?
If so, I'm wondering why Cassandra and Cosmos guarantee consistent reads since they don't support transactions. Cassandra can provide per-partition strongly consistent reads (this consistency is mutual consistency between replicas, so it's different from the consistency in the property), but it cannot provide consistent reads across multiple read operations, even for the same partition.

@feeblefakie feeblefakie marked this pull request as draft November 21, 2025 02:17
@brfrn169
Copy link
Collaborator Author

Since I need to revise the changes based on the discussion, I will close this PR.

@brfrn169 brfrn169 closed this Nov 21, 2025
@brfrn169 brfrn169 deleted the add-isConsistentReadGuaranteed-to-StorageInfo branch November 21, 2025 02:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants